package net.zoneland.zrdp.framework.web.domain.mapstruct;


import net.zoneland.uniflow.client.*;
import net.zoneland.zrdp.common.core.page.Pager;

import net.zoneland.zrdp.framework.web.domain.uniflow.ReadObjectPojo;
import net.zoneland.zrdp.framework.web.domain.uniflow.TaskEmailPojo;
import net.zoneland.zrdp.framework.web.domain.uniflow.TaskObjectPojo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * 流程业务处理转换.
 *
 * @version v1.0
 */
@Mapper
public interface UniflowConverter {

    UniflowConverter INSTANCE = Mappers.getMapper(UniflowConverter.class);

    /** 流程待办任务对象转换. **/
    List<TaskObjectPojo> taskToTaskPojo(final List<TaskObject> taskObjectList);

    /** 流程最新待办任务对象转换. **/
    List<TaskObjectPojo> applyTaskToTaskPojo(final List<ApplyTaskObject> applyTaskObjectList);

    /** 流程待阅任务对象转换. **/
    List<ReadObjectPojo> readToReadPojo(final List<ReadObject> readObjectList);

    /** 将任务分页结果转化成Pager格式. **/
    @Mapping(target = "list",
        expression = ("java(taskToTaskPojo(java.util.Arrays.asList(taskPageObject.getTaskObjects())))"))
    @Mapping(target = "currPage", source = "pageNumber")
    Pager<TaskObjectPojo> transformTasksToPager(final TaskPageObject taskPageObject);

    /** 将最新任务分页结果转化成Pager格式. **/
    @Mapping(target = "list",
        expression = ("java(applyTaskToTaskPojo(java.util.Arrays.asList(applyTaskPageObject.getApplyTasks())))"))
    @Mapping(target = "currPage", source = "pageNumber")
    Pager<TaskObjectPojo> transformTasksToPager(final ApplyTaskPageObject applyTaskPageObject);

    /** 将待阅任务分页结果转化成Pager格式. **/
    @Mapping(target = "list",
        expression = ("java(readToReadPojo(java.util.Arrays.asList(readPageObject.getReadObjects())))"))
    @Mapping(target = "currPage", source = "pageNumber")
    Pager<ReadObjectPojo> transformTasksToPager(final ReadPageObject readPageObject);



    /** 流程待办任务对象转换发送邮件. **/
    List<TaskEmailPojo> taskToTaskEmailPojoList(final List<TaskObject> taskObjectList);

    /** 流程待阅任务对象转换发送邮件. **/
    List<TaskEmailPojo> readToTaskEmailPojoList(final List<ReadObject> readObjectList);

}
